package com.clayecloud.common.client.services.Impl;

import com.clayecloud.common.client.services.VisitorService;
import com.clayecloud.common.entity.Visitor;
import com.clayecloud.common.mappers.VisitorMapper;
import com.clayecloud.common.utils.MessageUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author ClayeLink
 * @date 2022/4/8 15:59
 */
@Service
public class VisitorServiceImpl implements VisitorService {

    @Resource
    private VisitorMapper visitorMapper;

    @Override
    public MessageUtil insert(Visitor visitor) {
        return visitorMapper.insertSelective(visitor) > 0 ? MessageUtil.success("添加成功") : MessageUtil.fail("添加失败，请联系管理员");
    }

    @Override
    public MessageUtil<List<Visitor>> selectByUserID(Long userID) {
        return MessageUtil.success("查询成功").add(visitorMapper.selectByUserID(userID));
    }
}
